#ifndef TOOL_MATH_HPP_INCLUDED
#define TOOL_MATH_HPP_INCLUDED

/**************************************************************************************************
 *
 * This file contains mathematic functions for \code namespace betterShooter.
 *
 **************************************************************************************************/

#include <cmath>

namespace shooter
{
namespace tool_math
{

  /**
   * @brief  Use a template struct for static const value beacuse hpp file can not have static
   *         value unless using template.
   */
  template <int dummy>
  struct basic_parms
  {
    static const double C_Pi2;
    static const double C_Pi;
  };

  template <int dummy>
  const double basic_parms<dummy>::C_Pi2 = std::asin(1);
  template <int dummy>
  const double basic_parms<dummy>::C_Pi = 2 * C_Pi2;

  /**
   * @brief  calculate the magnitude of one edge by its sub edges.
   */
  template <class T>
  T cal_mag(T edge1, T edge2)
  {
    return std::sqrt(edge1*edge1 + edge2*edge2);
  }
  template <class T>
  T cal_mag(T edge1, T edge2, T edge3)
  {
    return std::sqrt(edge1*edge1 + edge2*edge2 + edge3*edge3);
  }

} // namespace tool_math
} // namespace shooter


#endif
